home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4416 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  59 lines

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP!!!!!!!
  5. Date: 03 Feb 1996 17:03:24 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb3100324@qcd.lanl.gov>
  8. References: <3112CFDA.85@utoronto.ca>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: Dave Goldstein's message of Sat, 3 Feb 1996 03:00:42 GMT
  13.  
  14. In article <3112CFDA.85@utoronto.ca> Dave Goldstein
  15. <dave.goldstein@utoronto.ca> writes: 
  16. <snip>
  17.    I am a frustrated new C programmer, with a big headache:
  18.    I've composed a linked list in a function, and I am passing the HEAD of 
  19.    the list into the function.  Of course, when I pass this into the 
  20.    function, I have to dereference it twice (**head) since I pass it in as 
  21.    &head.  Anyway, to make a long story short, when I try accessing the 
  22.    first item in the linked list (assuming there is one), I have tried 
  23.    accessing it as **head->next which C doesn't seem to like. WHY????!!
  24.    It keeps giving me an error "Pointer to structure required on left side 
  25.    of -> or ->* in function ....".  Isn't that what I'm doing??
  26.  
  27.    Please help, I'm beginning to feel suicidal!
  28.  
  29. You would be well advised to post code instead of committing
  30. suicide. Do not assume we are mind readers ... show us what you are
  31. doing. 
  32.  
  33. Also be advised that your compiler seems to be willing to accept C++
  34. code. C and C++ are different languages: make up your mind which you
  35. are learning. A new C programmer does not need to know C++, and many
  36. believe the converse is also true. (It is quite possible that I am
  37. mistaken and your compiler will actually warn you if you use C++
  38. constructs.)
  39.  
  40. As to your original question, given
  41.  
  42. struct X a;   you may refer to the fields as  a.f or (&a)->f
  43. struct X *b;  you may refer to the fields as  b->f or (*b).f
  44. struct X **c; you may refer to the fields as  (*c)->f or (**c).f
  45.  
  46. etc. 
  47.  
  48. Hope you see the pattern.
  49.  
  50. Cheers
  51. Tanmoy
  52. --
  53. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  54. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  55. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  56. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  57. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  58. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  59.